<template>
  <div class="more">
    <!-- shopinfo.info && shopinfo.info.poi_back_pic_url 这是为了防止组件初次渲染时shopinfo是空对象,导致的报错 -->
    <!-- <div class="top" :style="{backgroundImage:`url(${shoplist.info&& shoplist.info.poi_back_pic_url})`}">
        <img class="tou" :src="shoplist.info&& shoplist.info.picUrl" alt="">
      </div> -->
    <div class="top">
      <input type="text" placeholder="搜索" />
      <p
        @click="handle(index)"
        v-for="(item, index) in matches"
        :key="index"
        :class="{ match: true, active: currentIndex == index }"
      >
        {{ item }}
      </p>
      <!-- <div class="doc">{{this.$route.params.id}}</div> -->
    </div>
    <div class="center">
      <div class="left">
        <!-- 分类列表 -->
        <div
          @click="cerrent = index"
          class="cate"
          v-for="(item, index) in shoplist.taglist"
          :key="index"
        >
          {{ item.name }}
        </div>
      </div>
      <div class="right">
        <!-- 商品列表 -->
        <div
          class="good"
          v-for="(item, index) in shoplist.taglist &&
          shoplist.taglist[cerrent].goodlist"
          :key="index"
        >
          <div class="img-box">
            <img :src="item.picture" alt="" />
          </div>
          <div class="text">
            <div class="name">{{ item.name }}</div>
            <div class="price">{{ item.min_price }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { shop_shopinfo } from "../api";
export default {
  data() {
    return {
      shoplist: [],
      matches: ["点餐", "评价", "商家"],
      currentIndex: 0,
      cerrent: 0,
    };
  },
  mounted() {
    shop_shopinfo({ id: this.$route.params.id }).then((res) => {
      // console.log(res.data.shopinfo);
      // this.shoplist = res.data.shopinfo;
      if (res.data.code == 200) {
        console.log(res.data.shopinfo);
        this.shoplist = res.data.shopinfo;
      } else {
        alert(res.data.msg);
        this.$router.go(-1);
      }
    });
  },
  methods: {
    handle(index) {
      this.currentIndex = index;
    },
  },
};
</script>

<style scoped>
.more {
  width: 100%;
  height: 100%;
  /* background-color: aquamarine; */
}
.top {
  width: 100%;
  height: 100px;
  background-color: azure;
  overflow: hidden;
  display: flex;
}
input {
  width: 70px;
  height: 30px;
  display: block;
  outline: none;
  border-radius: 10px;
  border: none;
  text-align: center;
  line-height: 30px;
  margin-top: 20px;
  margin-left: 20px;
  border: 1px solid palegoldenrod;
}
.match {
  width: 50px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  margin-top: 20px;
}
.active {
  color: blue;
  border-bottom: 1px solid blueviolet;
}
.center {
  width: 100%;
  height: 650px;
  display: flex;
  overflow: auto;
}
.left {
  width: 150px;
  /* background-color: aqua; */
  /* height: 100%; */
  /* height: 30px; */
}
.cate {
  margin-top: 10px;
  height: 50px;
}
.right {
  flex: 1;
}
.good {
  display: flex;
  height: 100px;
  width: 100%;
  margin-top: 10px;
}
.img-box {
  width: 50px;
  height: 50px;
}
img {
  width: 50px;
  height: 50px;
}
</style>